﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Wicresoft.UnifyShow.Portal.Extensions
{
    public static class StatusHelper
    {
        public static string IncidentStatus(decimal? statusD)
        {
            int status;
            if (statusD.HasValue && int.TryParse(statusD + "", out status))
            {
                switch (status)
                {
                    case 0:
                        return "新建";
                    case 1:
                        return "已指派";
                    case 2:
                        return "进行中";
                    case 3:
                        return "暂停";
                    case 4:
                        return "已解决";
                    case 5:
                        return "已关闭";
                    case 6:
                        return "已取消";
                    default:
                        return string.Empty;
                }
            }
            return string.Empty;
        }
        public static string IncidentImpact(decimal? statusD)
        {
            int status;
            if (statusD.HasValue && int.TryParse(statusD + "", out status))
            {
                switch (status)
                {
                    case 1000:
                        return "严重";
                    case 2000:
                        return "较大";
                    case 3000:
                        return "一般";
                    default:
                        return string.Empty;
                }
            }
            return string.Empty;
        }
        public static string IncidentSeverity(decimal? statusD)
        {
            int status;
            if (statusD.HasValue && int.TryParse(statusD + "", out status))
            {
                switch (status)
                {
                    case 2000:
                        return "高";
                    case 3000:
                        return "中";
                    case 4000:
                        return "低";
                    default:
                        return string.Empty;
                }
            }
            return string.Empty;
        }
        public static string IncidentPriority(decimal? statusD)
        {
            int status;
            if (statusD.HasValue && int.TryParse(statusD + "", out status))
            {
                switch (status)
                {
                    case 1:
                        return "高";
                    case 2:
                        return "中";
                    case 3:
                        return "低";
                    default:
                        return string.Empty;
                }
            }
            return string.Empty;
        }
        public static string IncidentCloseCode(decimal? statusD)
        {
            int status;
            if (statusD.HasValue && int.TryParse(statusD + "", out status))
            {
                switch (status)
                {
                    case 19000:
                        return "根本解决";
                    case 15000:
                        return "不成功解决";
                    case 16000:
                        return "变通方法解决";
                    case 1000:
                        return "消失";
                    case 14000:
                        return "误报";
                    case 17000:
                        return "用户误操作";
                    default:
                        return string.Empty;
                }
            }
            return string.Empty;
        }
        public static string SLAStatus(decimal? statusD)
        {
            int status;
            if (statusD.HasValue && int.TryParse(statusD + "", out status))
            {
                switch (status)
                {
                    case 1:
                        return "达标";
                    case 4:
                        return "达标";
                    case 5:
                        return "未达标";
                    case 7:
                        return "未达标";
                    case 9:
                        return "告警";
                    default:
                        return string.Empty;
                }
            }
            return string.Empty;
        }

        public static string ReportTitle(string className, string methodName)
        {

            if (className == "Incident" && methodName == "IncidentApproveCount")
            {
                return "事件成功关闭百分比";
            }
            else if (className == "Incident" && methodName == "IncidentCount")
            {
                return "事件总数";
            }
            else if (className == "Incident" && methodName == "IncidentCloseCode")
            {
                return "事件原因分析";
            }
            else if (className == "Incident" && methodName == "IncidentAvgTime")
            {
                return "事件平均解决时间";
            }
            else if (className == "Incident" && methodName == "IncidentEscalation")
            {
                return "事件升级率";
            }
            else if (className == "Incident" && methodName == "IncidentImpact")
            {
                return "重大事件百分比";
            }
            else if (className == "Incident" && methodName == "IncidentResolvedTimeOut")
            {
                return "规定时间内解决的事件百分比";
            }
            else if (className == "Incident" && methodName == "IncidentResolvedGroup")
            {
                return "一二线解决率";
            }
            else if (className == "ServiceDesk" && methodName == "IncidentSource")
            {
                return "事件来源";
            }
            else if (className == "ServiceDesk" && methodName == "IncidentResolvedByServiceDesk")
            {
                return "服务台事件解决率";
            }
            else if (className == "Problem" && methodName == "PrimaryCauseProblem")
            {
                return "已确定根本原因的问题百分比";
            }
            else if (className == "Problem" && methodName == "ProblemCount")
            {
                return "问题总数";
            }
            else if (className == "Problem" && methodName == "EscalationProblem")
            {
                return "事件升级问题百分比";
            }
            else if (className == "Problem" && methodName == "ImpactProblem")
            {
                return "重大问题百分比";
            }
            else if (className == "Problem" && methodName == "FirmProStatusProblem")
            {
                return "供应商解决问题百分比";
            }
            else if (className == "Problem" && methodName == "AvgResolveTimeProblem")
            {
                return "平均问题解决时间";
            }
            else if (className == "Problem" && methodName == "ClosedProblem")
            {
                return "关闭问题百分比";
            }
            else if (className == "Problem" && methodName == "SolveProblem")
            {
                return "根本解决的问题百分比";
            }
            else if (className == "Problem" && methodName == "TimeOutProblem")
            {
                return "超时问题百分比";
            }
            else if (className == "Change" && methodName == "TimeOut")
            {
                return "超时的变更百分比";
            }
            else if (className == "Change" && methodName == "ChangeCount")
            {
                return "变更总数";
            }
            else if (className == "Change" && methodName == "ResultSort")
            {
                return "变更实施结果分类百分比";
            }
            else if (className == "Change" && methodName == "ImpactSort")
            {
                return "重大变更百分比";
            }
            else if (className == "Change" && methodName == "SuccessResultSort")
            {
                return "变更实施成功的超时百分比";
            }
            else if (className == "Change" && methodName == "AvgTime")
            {
                return "变更平均完成时间";
            }
            else if (className == "Change" && methodName == "EscalationChange")
            {
                return "来自其他工单类型的变更数量";
            }
            if (className == "1" && methodName == "1")
            {
                return "高优先级";
            }
            if (className == "1" && methodName == "2")
            {
                return "中优先级";
            }
            if (className == "1" && methodName == "3")
            {
                return "低优先级";
            }
            else
            {
                throw new InvalidOperationException("");
            }

        }
    }
}
